package com.joinlabs.action;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.servlet.ModelAndView;

import com.joinlabs.entity.Log;
import com.joinlabs.entity.Weibo;
import com.joinlabs.service.IForwardService;
import com.joinlabs.service.ILogService;
import com.joinlabs.service.ITopicService;
import com.joinlabs.service.IUserService;
import com.joinlabs.service.IWeiboService;


@Controller
@RequestMapping("/show")
@SessionAttributes(names= {"user","originalList"})	//声明要操作session域中的 多个 域对象的名字
public class FriendPageAction {
	
	@Resource
	private IUserService userService;//用户
	@Resource
	private ITopicService topicService;//话题
	@Resource
	private IWeiboService weiboService;//微博
	@Resource
	private IForwardService forwardService;//转发
	@Resource
	private ILogService logService;//日志
	
	@RequestMapping("/original")
	public ModelAndView showoriginal(ModelMap map) {
		
		//查询原创微博
		List<Weibo> originalList = weiboService.selectAllWeibo();
		map.addAttribute("originalList", originalList);
		
		//跳转到朋友圈界面并显示
		
		return new ModelAndView("/friendcycle/original");
	}
	@RequestMapping("/img")
	public ModelAndView showimg(ModelMap map) {
		
		//查询图片微博
		List<Weibo> imgWeiboList = weiboService.selectImgWeibo();
		map.addAttribute("imgWeiboList", imgWeiboList);
		
		return new ModelAndView("/friendcycle/img");
	}
	@RequestMapping("/article")
	public ModelAndView showarticle(ModelMap map) {
		
		//查询文章
		List<Log> logLists = logService.selectAllLog();
		map.addAttribute("logLists", logLists);
		System.out.println(logLists);
		
		return new ModelAndView("/friendcycle/article");
	}
	@RequestMapping("/friendCycle")
	public String friendCycle() {
		
		return "/friendcycle/weibo";
	}
}
